package com.example.gkcircle.utils;

import android.app.Activity;
import android.content.Context;

import com.bigkoo.alertview.AlertView;
import com.bigkoo.alertview.OnDismissListener;
import com.bigkoo.alertview.OnItemClickListener;
import com.example.gkcircle.R;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Jehu on 16/3/25.
 */
public class MyAlertView {


    public static AlertView alertView;

    public synchronized static void showAlertViewWithOK(Context context, String title, String content, String ok) {
        alertView = new AlertView(title, content, null, new String[]{ok}, null, context, AlertView.Style.Alert, new OnItemClickListener() {
            @Override
            public void onItemClick(Object o, int position) {

            }
        });
        alertView.show();
    }


    public static IShowAlertViewWithOkAndCancelListener iShowAlertViewWithOkAndCancelListener;

    public interface IShowAlertViewWithOkAndCancelListener {
        void onclickOk();
    }

    public static void showAlertViewWithOKAndCancel(final Activity activity, final String content, final IShowAlertViewWithOkAndCancelListener iShowAlertViewWithOkAndCancelListener) {
        MyAlertView.iShowAlertViewWithOkAndCancelListener = iShowAlertViewWithOkAndCancelListener;
        if(alertView==null){
            alertView = new AlertView("提示", content, "取消", new String[]{"取消"}, new String[]{"确定"}, activity, AlertView.Style.Alert, new OnItemClickListener() {
                @Override
                public void onItemClick(Object o, int position) {
                    if (position != AlertView.CANCELPOSITION) {
                        iShowAlertViewWithOkAndCancelListener.onclickOk();
                    }
                }
            }).setCancelable(true).setOnDismissListener(new OnDismissListener() {
                @Override
                public void onDismiss(Object o) {
                    CommonUtil.hideSoftInputView(activity);
                }
            });
        }
        alertView.show();
    }


}
